Skip to content

Commit

Permalink
Implement assign statements as BUF_BUILTIN
Browse files Browse the repository at this point in the history
  • Loading branch information
gtarawneh committed Nov 17, 2017
1 parent 82fa0f8 commit 3007d32
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
3 changes: 3 additions & 0 deletions gates/builtins.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module BUF_BUILTIN (output out, input inp);
assign out = inp;
endmodule
6 changes: 4 additions & 2 deletions generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
from jinja2 import Template
from sg_parser import load_sg
from lib_parser import load_lib
from lib_parser import merge_libs
from lib_parser import builtins_lib
from collections import defaultdict
from verilog_parser import load_verilog
from lib_parser import merge_libs

import os
import re
Expand Down Expand Up @@ -93,7 +94,8 @@ def main():

output_dir = "generated"

lib = load_lib("libraries/workcraft.lib")
lib_wk = load_lib("libraries/workcraft.lib")
lib = merge_libs(lib_wk, builtins_lib)
spec = load_sg("examples/SRAM-master/spec.sg")
circuit = load_verilog("examples/SRAM-master/circuit.v")

Expand Down
3 changes: 1 addition & 2 deletions lib_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@


builtins_lib = {
"*assign": {
"BUF_BUILTIN": {
"type": "GATE",
"state_input": None,
"name": "*assign",
"output": "out",
"inputs": ["inp"],
"definition": "out=inp",
Expand Down
2 changes: 1 addition & 1 deletion templates/circuit.v
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module circuit (
{%- set pin_net = output_pre if pin==output_pin else net -%}
.{{pin}}({{pin_net}}){{ ", " if not loop.last }}
{%- endfor -%}
);
); {{"// virtual module" if mod.get("virtual")}}

DFF {{instance}}_ff (
.CK(clk),
Expand Down
7 changes: 4 additions & 3 deletions verilog_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ def add_assign(circuit, out, inp):
# prefixed with * to make them non-compliant with the Verilog standard (and
# thus obviously in need of special treatment).

instance = "*%s" % out
instance = "ASSIGN_%s" % out

circuit["modules"][instance] = {
"type": "*assign",
"connections": { "inp": inp, "out": out }
"type": "BUF_BUILTIN",
"connections": { "inp": inp, "out": out },
"virtual": True
}


Expand Down

0 comments on commit 3007d32

Please sign in to comment.