Commits

Lionel Flandrin  committed 7509399

Added "spaced" printers for verilog

  • Participants
  • Parent commits 6b6a434

Comments (0)

Files changed (5)

   this->printers["vd"] = new PrintVerilog(10);
   this->printers["vo"] = new PrintVerilog(8);
   this->printers["vb"] = new PrintVerilog(2);
+  this->printers["vs"]  = new PrintVerilog(16, 2);
+  this->printers["vhs"] = new PrintVerilog(16, 2);
+  this->printers["vds"] = new PrintVerilog(10, 3);
+  this->printers["vos"] = new PrintVerilog(8,  3);
+  this->printers["vbs"] = new PrintVerilog(2,  4);
   this->printers["s"]  = new PrintSize(1024, "B");
   this->printers["si"]  = new PrintSize(1000, "");
 
 }
 
 
-PrintVerilog::PrintVerilog(int b)
-  :base(b)
+PrintVerilog::PrintVerilog(int b, unsigned s)
+  :base(b), spacing(s)
 {
   switch(this->base) {
   case 16:
     o << 's';
   }
 
-  print_integer_base(o, v, this->base, this->prefix, 0);
+  print_integer_base(o, v, this->base, this->prefix, this->spacing);
 }
 
 
 
   class PrintVerilog : public Printer {
   private:
-    int          base;
-    const char  *prefix;
+    int         base;
+    unsigned    spacing;
+    const char *prefix;
 
   public:
-    PrintVerilog(int);
+    PrintVerilog(int, unsigned = 0);
     virtual void print_integer(std::ostream &, const Integer &);
     /* No float format */
   };

File tests/expected-output.txt

 0xff
 0xe6_a9
 -0xe6_a9
+0'h0
+1'h1
+2'sh3
+3'h4
+5'sh16
+8'hff
+16'he6_a9
+17'sh1_19_57
 0*B
 0*B +0.01
 0 +0.00000050603

File tests/tests.txt

 3**10:hs
 -3**10:hs
 
+0:vs
+1:vs
+-1:vs
+4:vs
+-10:vs
+0xff:vs
+3**10:vs
+-3**10:vs
+
 0:s
 0.010:s
 0.00000050603:si