Atelier des rouesLab FR
Objects/Documentation

chiffres.v

I describe three variable-digit modulo-five circuits in Verilog.

Download ↓
// The same total combinational interface for all three descriptions.
module horner6(input [2:0] r, input [5:0] b, output [2:0] y);
    wire [2:0] state [0:6];
    assign state[0] = r;
    genvar i;
    generate for (i=0; i<6; i=i+1) begin: stage
        wire [3:0] twice = {state[i], b[5-i]};
        wire [3:0] reduced = twice >= 4'd5 ? twice - 4'd5 : twice;
        assign state[i+1] = reduced[2:0];
    end endgenerate
    assign y = r < 5 ? state[6] : r;
endmodule

module lookup6(input [2:0] r, input [5:0] b, output [2:0] y);
    wire [2:0] rows [0:511];
    genvar j;

Read in context

Comments

Comments from both language editions appear here.

The discussion is open for reading. I’ll enable submissions once spam protection is configured.