I am trying to generate Gate Level Verilog initially from a function described in C/C++ language. My C function is a simple and gate:
_Bool and2gate(_Bool a, _Bool b)
{
return a && b;
}
Using Bambu-Panda tool
I managed to generate a Verilog description of this function:
`ifdef __ICARUS__
`define _SIM_HAVE_CLOG2
`endif
`ifdef VERILATOR
`define _SIM_HAVE_CLOG2
`endif
`ifdef MODEL_TECH
`define _SIM_HAVE_CLOG2
`endif
`ifdef VCS
`define _SIM_HAVE_CLOG2
`endif
`ifdef NCVERILOG
`define _SIM_HAVE_CLOG2
`endif
`ifdef XILINX_SIMULATOR
`define _SIM_HAVE_CLOG2
`endif
`ifdef XILINX_ISIM
`define _SIM_HAVE_CLOG2
`endif
`timescale 1ns / 1ps
module ui_bit_and_expr_FU(in1, in2, out1);
parameter BITSIZE_in1=1, BITSIZE_in2=1, BITSIZE_out1=1;
// IN
input [BITSIZE_in1-1:0] in1;
input [BITSIZE_in2-1:0] in2;
// OUT
output [BITSIZE_out1-1:0] out1;
assign out1 = in1 & in2;
endmodule
// Datapath RTL descrition for and2gate
`timescale 1ns / 1ps
module datapath_and2gate(clock, reset, in_port_a, in_port_b, return_port);
// IN
input clock;
input reset;
input in_port_a;
input in_port_b;
// OUT
output return_port;
// Component and signal declarations
wire [0:0] out_ui_bit_and_expr_FU_1_1_1_3_i0_fu_and2gate_21644_21668;
ui_bit_and_expr_FU #(.BITSIZE_in1(1), .BITSIZE_in2(1), .BITSIZE_out1(1)) fu_and2gate_21644_21668 (.out1(out_ui_bit_and_expr_FU_1_1_1_3_i0_fu_and2gate_21644_21668), .in1(in_port_a), .in2(in_port_b));
// io-signal post fix
assign return_port = out_ui_bit_and_expr_FU_1_1_1_3_i0_fu_and2gate_21644_21668;
endmodule
// FSM based controller descrition for and2gate
`timescale 1ns / 1ps
module controller_and2gate(done_port, clock, reset, start_port);
// IN
input clock;
input reset;
input start_port;
// OUT
output done_port;
parameter [0:0] S_0 = 1'd0;
reg [0:0] _present_state, _next_state;
reg done_port;
always @(posedge clock)
if (reset == 1'b0) _present_state <= S_0;
else _present_state <= _next_state;
always @(*)
begin
_next_state = S_0;
done_port = 1'b0;
case (_present_state)
S_0 :
if(start_port != 1'b1 )
begin
_next_state = S_0;
end
else
begin
_next_state = S_0;
done_port = 1'b1;
end
default :
begin
done_port = 1'b0;
end
endcase
end
endmodule
// Top component for and2gate
`timescale 1ns / 1ps
module and2gate(clock, reset, start_port, done_port, a, b, return_port);
// IN
input clock;
input reset;
input start_port;
input a;
input b;
// OUT
output done_port;
output return_port;
// Component and signal declarations
controller_and2gate Controller_i (.done_port(done_port), .clock(clock),
.reset(reset), .start_port(start_port));
datapath_and2gate Datapath_i (.return_port(return_port), .clock(clock),
.reset(reset), .in_port_a(a), .in_port_b(b));
endmodule
// Minimal interface for top component: and2gate
`timescale 1ns / 1ps
module and2gate_minimal_interface(clock, reset, start_port, a, b, done_port, return_port);
// IN
input clock;
input reset;
input start_port;
input a;
input b;
// OUT
output done_port;
output return_port;
// Component and signal declarations
and2gate and2gate_i0 (.done_port(done_port), .return_port(return_port), .clock(clock), .reset(reset), .start_port(start_port), .a(a), .b(b));
endmodule
However, this in not a gate level verilog as I understand. What I would like to do is to create a SINGLE module netlist Verilog (Gate Level Verilog with a single module).
I understand that Yosys tool allows to create such Verilog. However, I could not reach the desired output. I would like an output in the following fomat format:
module top (input clk, // clock
input rst, // reset
input g_init, //for sequential circuits, initial value for
registers from garbler. Only read in first clock cycle
input e_init, //same for evaluator
input g_input, // garbler's input
input e_input,//evaluator's input
output o // output
);
I'll appreciate very much an explanation on how to generate this kind of Gate Level code from the higher level verilog above, either using Yosys or some other synthesis and sim tool.
I will also appreciate any suggestions on how to generate Verilog from C code and which tools are recommended for such a task?