Describe oprtations
Write each operation.
The calculation result has 9-bit bus so that we can easily generate the carry flag.
After that, carry flag and operation result are reassigned to each variable.
Notes;
- Followint operators are not used, multiply "*", divide "/", right shift ">>" and left "<<" because these operator make large circuits.
In this exercise, one bit shift operations are writen by bit manupiration.
- Signal tmp has carry signal.
- Separatoer // is followed by comment.
...
reg [8:0] tmp; // operation result
always @( ... or ... or ... )
begin
case ( CB )
`IADD : tmp <= { 1'b0, A } + { 1'b0, B }; // addition
...
...
...
`ISWP : tmp <= { 1'b0, A[3:0], A[7:4] }; // nibble swap
default : tmp <= 9'bxxxxxxxxx; // don't care (for simulation)
endcase
end
...
...
assign Y = ... ; // reassignment of result
...
Next, describe flags .
| Back |
CAD Home |