ElEctric_EyE wrote:
It would be ideal to be able to transfer a value from any accumulator/register, but there are no src_reg, dst_reg.
A simple trick is to use a shadow register in the register file. If you don't mind sacrificing a register, you could use one of the existing registers, like you tried before. Let's say you define 'Z' to be your zero page register. To avoid making the register file multi-ported, you add an extra '[15:0] zp_reg', and whenever you write the Z register, you write zp_reg with the same value:
Code:
always @(posedge clk)
if( write_register & RDY & (regsel == SEL_Z) )
zp_reg <= ADD;
And then you can simply use the zp_reg instead of ZEROPAGE in the AB signal.
Now, if you don't need the full set of operations on the Z register, and you don't want to waste a register in the register file you can make special register file entries. To do that, you extend the register file from 16 to 32, and define SEL_ZP as 16. Other special registers can be numbered 17..31. Also, src_reg/dst_reg/regsel need to be adjusted to 5 bits. Now, whenever you see your new TxZP opcode (transfer from regular register to ZP), set dst_reg <= SEL_ZP, and when you see the TZPx, set src_reg <= SEL_ZP.