[J-core] Is there documentation for vhm files and the v2p script?

D. Jeff Dionne Jeff at SE-Instruments.com
Tue Jul 19 00:08:32 EDT 2016


Sorry, about that, I kinda regret writing it in perl, but regex is what made it possible in such short code.

The best way to understand *exactly* what it does is:

JeffAir:components jeff$ cd cpu/core/
JeffAir:core jeff$ perl ../../../tools/v2p < mult.vhm > mult.vhd
JeffAir:core jeff$ diff -wur mult.vhm mult.vhd 
--- mult.vhm	2016-05-09 19:03:09.000000000 +0900
+++ mult.vhd	2016-07-19 13:05:05.000000000 +0900
@@ -12,11 +12,12 @@
 end mult;
 
 architecture stru of mult is
-  register variable this : mult_reg_t reset := MULT_RESET;
+  signal this_c : mult_reg_t;
+  signal this_r : mult_reg_t := MULT_RESET;
 
   begin
-  mult : process(this, slot, a)
-  register this when clk='1' and clk'event reset when rst='1';
+  mult : process(this_r, slot, a)
+  variable this : mult_reg_t;
   variable aa    : std_logic_vector(31 downto 0);
   variable ah    : std_logic_vector(30 downto 0);
   variable bh    : std_logic_vector(15 downto 0);
@@ -31,6 +32,8 @@
   variable sat   : std_logic;
   variable code  : mult_codeline_t;
   begin
+     this := this_r;
+
     code := MULT_CODE(this.state);
     y.busy <= code.busy; -- FIXME: warning : combinatorial output
 
@@ -152,9 +155,20 @@
         if a.s = '1' then this.result_op := SATURATE32; this.state := MACWS; end if;
       end if;
     end if;
+
+    this_c <= this;
+  end process;
+
+  mult_r0 : process(clk, rst)
+  begin
+     if rst='1' then
+        this_r <= MULT_RESET;
+     elsif clk='1' and clk'event then
+        this_r <= this_c;
+     end if;
   end process;
 
   -- drive the outputs
-  y.mach <= this'register.mach;
-  y.macl <= this'register.macl;
+  y.mach <= this_r.mach;
+  y.macl <= this_r.macl;
 end stru;
JeffAir:core jeff$ 


> On Jul 19, 2016, at 1:01 PM, Robert Ou <rqou at robertou.com> wrote:
> 
> Hi,
> 
> I understand that the purpose of v2p is to help enforce a particular
> coding style for VHDL that keeps registers and "everything else"
> separate, but is there any documentation for how it works?
> Unfortunately, I am not very familiar with either Perl or regexes so
> reading through the source code for v2p is quite a slow way to
> discover how it works.
> 
> Robert
> _______________________________________________
> J-core mailing list
> J-core at lists.j-core.org
> http://lists.j-core.org/mailman/listinfo/j-core



More information about the J-core mailing list