rwiker wrote:
Will this be possible to get running on other FPGA architectures, or will it be completely tied to Spartan 6 & 7?
The goal is to make it generic so that it can be targeted for any architecture, but with the structure of the FPGA in mind. For instance, each little combinatorial block is made so that it fits in 6-input LUTs. It will still work on an older 4-input LUT, but it won't be so efficient.
If I need 7+ inputs, I try everything I can to push some of the logic somewhere else. Likewise, when I need less than 6, I try to add some functionality. That's the reason I ended up with a block RAM, because I could not figure out a (good) way to do the instruction decoding with only 6 inputs (especially not with the irregular 65C02 extensions thrown in).
When the generic model is ready, I want to try to hand optimize for Spartan, by providing an alternative implementation of some of the modules (that's the main reason for the current, small, modules, such as the ALU, ABL, and ABH), so you can simply remove the generic version of the model, and replace it with the Spartan-6 specific. Somebody else may be able to provide targeted code for other FPGAs.
For example, the adder/logic block in the ALU should fit in a single LUT per bit on Spartan 6/7, using 2 inputs for the R/M inputs, and 3 for the operation select bits. When using the carry chain logic, you need two signals (Generate and Propagate). The Spartan 6 can split the LUT6 into a pair of LUT5s to generate those two signals, as long as you restrict yourself to total of 5 inputs.
Code:
always @(*)
case( op[2:0] )
3'b000: adder = R | M + CI;
3'b001: adder = R & M + CI;
3'b010: adder = R ^ M + CI;
3'b011: adder = R + M + CI;
3'b100: adder = R + 8'h00 + CI;
3'b101: adder = R + 8'hff + CI;
3'b110: adder = R + ~M + CI;
3'b111: adder = ~R & M + CI;
endcase