summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodrigo Alejandro Melo <rmelo@inti.gob.ar>2017-11-16 13:02:29 -0300
committerRodrigo Alejandro Melo <rmelo@inti.gob.ar>2017-11-16 13:02:29 -0300
commit3d45f0322dca3cb60b818cb28afc077b6e6d29b3 (patch)
tree6ec53c903a1dab87c0c59830a95aaa9d39a81967
parent6252447712e65498ba7b37d03f4832ecb645db44 (diff)
downloadvhdl2vl-3d45f0322dca3cb60b818cb28afc077b6e6d29b3.tar.gz
vhdl2vl-3d45f0322dca3cb60b818cb28afc077b6e6d29b3.zip
Added (partial) support for to_integer function
Added an example that fail to todo.vhd.
-rw-r--r--examples/todo.vhd8
-rw-r--r--src/vhd2vl.l1
-rw-r--r--translated_examples/mem.v4
3 files changed, 9 insertions, 4 deletions
diff --git a/examples/todo.vhd b/examples/todo.vhd
index 2a5b239..a5695ee 100644
--- a/examples/todo.vhd
+++ b/examples/todo.vhd
@@ -10,15 +10,19 @@ entity todo is
end todo;
architecture rtl of todo is
+ type mem_type is array (0 to 255) of integer;
+ signal mem : mem_type;
+
signal int : integer;
signal uns : unsigned(7 downto 0);
begin
--**************************************************************************
-- Wrong translations
--**************************************************************************
- -- to_integer is unsupported (is not removed)
+ -- to_integer not always work (probably the same with conv_integer)
uns <= "10101001";
- int <= to_integer(uns);
+ int <= mem(to_integer(uns)); -- here work
+ int <= to_integer(uns); -- here fail
--**************************************************************************
-- Translations which abort with syntax error (uncomment to test)
--**************************************************************************
diff --git a/src/vhd2vl.l b/src/vhd2vl.l
index e7419de..5c88605 100644
--- a/src/vhd2vl.l
+++ b/src/vhd2vl.l
@@ -126,6 +126,7 @@ void getbasedstring(unsigned skip);
"falling_edge" { return NEGEDGE;}
"resize" { return CONVFUNC_2;}
"to_unsigned" { return CONVFUNC_2;}
+"to_integer" |
"conv_integer" { return CONVFUNC_1;}
"left" { return LEFT;}
"high" { return LEFT;}
diff --git a/translated_examples/mem.v b/translated_examples/mem.v
index 18e36c4..8ab38cc 100644
--- a/translated_examples/mem.v
+++ b/translated_examples/mem.v
@@ -21,11 +21,11 @@ parameter [31:0] bus_width=14;
reg [bus_width - 1:0] mem[255:0];
reg [addr_width - 1:0] al = 8'h00;
- assign dout = mem[al];
+ assign dout = mem[(al)];
always @(posedge clk) begin
al <= addr;
if(en == 1'b1) begin
- mem[addr] <= din;
+ mem[(addr)] <= din;
end
end
OpenPOWER on IntegriCloud