Skip to content

Pure combinational circuit without registers possible? #603

Answered by rsnikhil
ju-sh asked this question in Q&A
Discussion options

You must be logged in to vote

Certainly, you can express arbitrary combinational circuits in BSV.

Broadly speaking, any BSV expression with a "value type" (not involving Action or ActionValue types) represents a combinational circuit. For example, given two 1-bit signals 'a' and 'b', the expression

{(a & b, a ^ b}

represents a half-adder with the sum and carry bits. Any expression can be encapsulated into a function, e.g.,

function Bit #(2) half_adder (Bit #(1) a, Bit #(1) b);
   Bit #(1) s = a ^ b;
   Bit #(1) c = a & b;
   return { c, s };
endfunction

The following is a full adder, which also takes an carry-in bit argument:

function Bit #(2) fa (Bit #(1) a, Bit #(1) b, Bit #(1) c_in);
   Bit #(2) ab    = ha (a, b)…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by rsnikhil
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants