In Bluespec registers are considered atomic units with regard to their updates. That is, if any bit of a register is updated, then the entire register is considered updated. As an example, consider the follow code fragment. There are two rules which each update a separate byte of a 32 bit register. Bluespec semantics say that these two rules conflict, since both are updating the same register.
Reg#(Bit#(32)) reg1 <- mkReg(0) ;
A better methodology is to define four 8-bit registers, and update the bytes a needed, if this is the intended behavior. This style of coding has been observed to have better synthesis results.
Reg#(Bit#(8)) regA1 <- mkReg(0) ;
Convenience functions can also be written to make the reading and writing of these registers easier.
function Action updateRegA( Bit#(32) din ) ; |
Learning BSV > Advanced Bluespec >