Add a sign-extension node.
This commit is contained in:
parent
06e08dbdf0
commit
b6fd4f610b
|
|
@ -16,7 +16,7 @@
|
|||
# 59 Temple Place - Suite 330
|
||||
# Boston, MA 02111-1307, USA
|
||||
#
|
||||
#ident "$Id: Makefile.in,v 1.67 2005/04/28 04:59:53 steve Exp $"
|
||||
#ident "$Id: Makefile.in,v 1.68 2005/05/24 01:43:27 steve Exp $"
|
||||
#
|
||||
#
|
||||
SHELL = /bin/sh
|
||||
|
|
@ -82,7 +82,7 @@ vpi_memory.o vpi_vthr_vector.o vpip_bin.o vpip_hex.o vpip_oct.o \
|
|||
vpip_to_dec.o vpip_format.o vvp_vpi.o
|
||||
|
||||
O = main.o parse.o parse_misc.o lexor.o arith.o bufif.o compile.o concat.o \
|
||||
dff.o functor.o npmos.o part.o reduce.o resolv.o stop.o symbols.o \
|
||||
dff.o extend.o functor.o npmos.o part.o reduce.o resolv.o stop.o symbols.o \
|
||||
ufunc.o codes.o \
|
||||
vthread.o schedule.o statistics.o tables.o udp.o vvp_net.o memory.o \
|
||||
event.o logic.o delay.o words.o $V
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* $Id: README.txt,v 1.66 2005/05/08 23:40:14 steve Exp $
|
||||
* $Id: README.txt,v 1.67 2005/05/24 01:43:27 steve Exp $
|
||||
*/
|
||||
|
||||
VVP SIMULATION ENGINE
|
||||
|
|
@ -524,6 +524,16 @@ the device has a single input, which is a vector of any width. The
|
|||
device performs the logic on all the bits of the vector (a la Verilog)
|
||||
and produces and propagates a single bit width vector.
|
||||
|
||||
EXPANSION LOGIC
|
||||
|
||||
Sign extension nodes are the opposite of reduction logic, in that they
|
||||
take a narrow vector, or single bit, and pad it out to a wider
|
||||
vector.
|
||||
|
||||
<label> .expand/s <wid>, <symbol> ;
|
||||
|
||||
The .expand/s node takes an input symbol and sign-extends it to the
|
||||
given width.
|
||||
|
||||
FORCE STATEMENTS (old method - remove me):
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: compile.cc,v 1.201 2005/05/18 03:46:01 steve Exp $"
|
||||
#ident "$Id: compile.cc,v 1.202 2005/05/24 01:43:27 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "arith.h"
|
||||
|
|
@ -1037,6 +1037,23 @@ void compile_cmp_gt(char*label, long wid, bool signed_flag,
|
|||
make_arith(arith, label, wid, argc, argv);
|
||||
}
|
||||
|
||||
/*
|
||||
* Extend nodes.
|
||||
*/
|
||||
void compile_extend_signed(char*label, long wid, struct symb_s arg)
|
||||
{
|
||||
assert(wid >= 0);
|
||||
|
||||
vvp_fun_extend_signed*fun = new vvp_fun_extend_signed(wid);
|
||||
vvp_net_t*ptr = new vvp_net_t;
|
||||
ptr->fun = fun;
|
||||
|
||||
define_functor_symbol(label, ptr);
|
||||
free(label);
|
||||
|
||||
input_connect(ptr, 0, arg.text);
|
||||
}
|
||||
|
||||
/*
|
||||
* A .shift/l statement creates an array of functors for the
|
||||
* width. The 0 input is the data vector to be shifted and the 1 input
|
||||
|
|
@ -1526,6 +1543,9 @@ void compile_param_string(char*label, char*name, char*str, char*value)
|
|||
|
||||
/*
|
||||
* $Log: compile.cc,v $
|
||||
* Revision 1.202 2005/05/24 01:43:27 steve
|
||||
* Add a sign-extension node.
|
||||
*
|
||||
* Revision 1.201 2005/05/18 03:46:01 steve
|
||||
* Fixup structural GT comparators.
|
||||
*
|
||||
|
|
@ -1583,32 +1603,5 @@ void compile_param_string(char*label, char*name, char*str, char*value)
|
|||
*
|
||||
* Revision 1.184 2005/01/29 17:53:25 steve
|
||||
* Use scheduler to initialize constant functor inputs.
|
||||
*
|
||||
* Revision 1.183 2005/01/28 05:34:25 steve
|
||||
* Add vector4 implementation of .arith/mult.
|
||||
*
|
||||
* Revision 1.182 2005/01/22 16:21:11 steve
|
||||
* Implement vectored CMP_EQ and NE
|
||||
*
|
||||
* Revision 1.181 2005/01/22 01:06:20 steve
|
||||
* Implement the .cmp/eeq LPM node.
|
||||
*
|
||||
* Revision 1.180 2005/01/16 04:19:08 steve
|
||||
* Reimplement comparators as vvp_vector4_t nodes.
|
||||
*
|
||||
* Revision 1.179 2004/12/31 05:54:46 steve
|
||||
* Fix uninitialized fun pointer for resolver nodes.
|
||||
*
|
||||
* Revision 1.178 2004/12/17 04:47:47 steve
|
||||
* Replace single release with release/net and release/reg.
|
||||
*
|
||||
* Revision 1.177 2004/12/15 17:17:42 steve
|
||||
* Add the force/v instruction.
|
||||
*
|
||||
* Revision 1.176 2004/12/11 02:31:29 steve
|
||||
* Rework of internals to carry vectors through nexus instead
|
||||
* of single bits. Make the ivl, tgt-vvp and vvp initial changes
|
||||
* down this path.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: compile.h,v 1.71 2005/05/08 23:40:14 steve Exp $"
|
||||
#ident "$Id: compile.h,v 1.72 2005/05/24 01:43:27 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <stdio.h>
|
||||
|
|
@ -154,6 +154,8 @@ extern void compile_reduce_nand(char*label, struct symb_s arg);
|
|||
extern void compile_reduce_nor(char*label, struct symb_s arg);
|
||||
extern void compile_reduce_xnor(char*label, struct symb_s arg);
|
||||
|
||||
extern void compile_extend_signed(char*label, long width, struct symb_s arg);
|
||||
|
||||
extern void compile_repeat(char*label, long width, long repeat,
|
||||
struct symb_s arg);
|
||||
|
||||
|
|
@ -311,6 +313,9 @@ extern void compile_net(char*label, char*name,
|
|||
|
||||
/*
|
||||
* $Log: compile.h,v $
|
||||
* Revision 1.72 2005/05/24 01:43:27 steve
|
||||
* Add a sign-extension node.
|
||||
*
|
||||
* Revision 1.71 2005/05/08 23:40:14 steve
|
||||
* Add support for variable part select.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (c) 2005 Stephen Williams <steve@icarus.com>
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
* General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: extend.cc,v 1.1 2005/05/24 01:43:27 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vvp_net.h"
|
||||
# include "compile.h"
|
||||
# include <string.h>
|
||||
# include <stream.h>
|
||||
# include <assert.h>
|
||||
|
||||
vvp_fun_extend_signed::vvp_fun_extend_signed(unsigned wid)
|
||||
: width_(wid)
|
||||
{
|
||||
}
|
||||
|
||||
vvp_fun_extend_signed::~vvp_fun_extend_signed()
|
||||
{
|
||||
}
|
||||
|
||||
void vvp_fun_extend_signed::recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit)
|
||||
{
|
||||
if (bit.size() >= width_) {
|
||||
vvp_send_vec4(port.ptr()->out, bit);
|
||||
return;
|
||||
}
|
||||
|
||||
vvp_vector4_t res (width_);
|
||||
|
||||
for (unsigned idx = 0 ; idx < bit.size() ; idx += 1)
|
||||
res.set_bit(idx, bit.value(idx));
|
||||
|
||||
vvp_bit4_t pad = bit.size() > 0? bit.value(bit.size()-1) : BIT4_0;
|
||||
for (unsigned idx = bit.size() ; idx < res.size() ; idx += 1)
|
||||
res.set_bit(idx, pad);
|
||||
|
||||
vvp_send_vec4(port.ptr()->out, res);
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: lexor.lex,v 1.53 2005/05/08 23:40:14 steve Exp $"
|
||||
#ident "$Id: lexor.lex,v 1.54 2005/05/24 01:43:27 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "parse_misc.h"
|
||||
|
|
@ -101,6 +101,7 @@
|
|||
".dff" { return K_DFF; }
|
||||
".event" { return K_EVENT; }
|
||||
".event/or" { return K_EVENT_OR; }
|
||||
".extend/s" { return K_EXTEND_S; }
|
||||
".functor" { return K_FUNCTOR; }
|
||||
".net" { return K_NET; }
|
||||
".net/s" { return K_NET_S; }
|
||||
|
|
@ -195,6 +196,9 @@ int yywrap()
|
|||
|
||||
/*
|
||||
* $Log: lexor.lex,v $
|
||||
* Revision 1.54 2005/05/24 01:43:27 steve
|
||||
* Add a sign-extension node.
|
||||
*
|
||||
* Revision 1.53 2005/05/08 23:40:14 steve
|
||||
* Add support for variable part select.
|
||||
*
|
||||
|
|
|
|||
15
vvp/parse.y
15
vvp/parse.y
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: parse.y,v 1.74 2005/05/08 23:40:14 steve Exp $"
|
||||
#ident "$Id: parse.y,v 1.75 2005/05/24 01:43:27 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "parse_misc.h"
|
||||
|
|
@ -62,7 +62,8 @@ extern FILE*yyin;
|
|||
%token K_CMP_EEQ K_CMP_EQ K_CMP_NEE K_CMP_NE
|
||||
%token K_CMP_GE K_CMP_GE_S K_CMP_GT K_CMP_GT_S
|
||||
%token K_CONCAT K_DFF
|
||||
%token K_EVENT K_EVENT_OR K_FUNCTOR K_NET K_NET_S K_PARAM K_PART K_PART_PV
|
||||
%token K_EVENT K_EVENT_OR K_EXTEND_S K_FUNCTOR K_NET K_NET_S
|
||||
%token K_PARAM K_PART K_PART_PV
|
||||
%token K_PART_V K_REDUCE_AND K_REDUCE_OR K_REDUCE_XOR
|
||||
%token K_REDUCE_NAND K_REDUCE_NOR K_REDUCE_XNOR K_REPEAT
|
||||
%token K_RESOLV K_SCOPE K_SHIFTL K_SHIFTR K_THREAD K_TIMESCALE K_UFUNC
|
||||
|
|
@ -301,6 +302,13 @@ statement
|
|||
| T_LABEL K_REPEAT T_NUMBER ',' T_NUMBER ',' symbol ';'
|
||||
{ compile_repeat($1, $3, $5, $7); }
|
||||
|
||||
/* The extend nodes take a width and a symbol. */
|
||||
|
||||
| T_LABEL K_EXTEND_S T_NUMBER ',' symbol ';'
|
||||
{ compile_extend_signed($1, $3, $5); }
|
||||
|
||||
/* Shift nodes. */
|
||||
|
||||
| T_LABEL K_SHIFTL T_NUMBER ',' symbols ';'
|
||||
{ struct symbv_s obj = $5;
|
||||
compile_shiftl($1, $3, obj.cnt, obj.vect);
|
||||
|
|
@ -681,6 +689,9 @@ int compile_design(const char*path)
|
|||
|
||||
/*
|
||||
* $Log: parse.y,v $
|
||||
* Revision 1.75 2005/05/24 01:43:27 steve
|
||||
* Add a sign-extension node.
|
||||
*
|
||||
* Revision 1.74 2005/05/08 23:40:14 steve
|
||||
* Add support for variable part select.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ident "$Id: vvp_net.h,v 1.27 2005/05/09 00:36:58 steve Exp $"
|
||||
#ident "$Id: vvp_net.h,v 1.28 2005/05/24 01:43:27 steve Exp $"
|
||||
|
||||
# include "config.h"
|
||||
# include <assert.h>
|
||||
|
|
@ -490,6 +490,24 @@ class vvp_fun_drive : public vvp_net_fun_t {
|
|||
unsigned char drive1_;
|
||||
};
|
||||
|
||||
/*
|
||||
* EXTEND functors expand an input vector to the desired output
|
||||
* width. The extend_signed functor sign extends the input. If the
|
||||
* input is already wider then the desired output, then it is passed
|
||||
* unmodified.
|
||||
*/
|
||||
class vvp_fun_extend_signed : public vvp_net_fun_t {
|
||||
|
||||
public:
|
||||
explicit vvp_fun_extend_signed(unsigned wid);
|
||||
~vvp_fun_extend_signed();
|
||||
|
||||
void recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit);
|
||||
|
||||
private:
|
||||
unsigned width_;
|
||||
};
|
||||
|
||||
/* vvp_fun_part
|
||||
* This node takes a part select of the input vector. Input 0 is the
|
||||
* vector to be selected from, and input 1 is the location where the
|
||||
|
|
@ -721,6 +739,9 @@ class vvp_wide_fun_t : public vvp_net_fun_t {
|
|||
|
||||
/*
|
||||
* $Log: vvp_net.h,v $
|
||||
* Revision 1.28 2005/05/24 01:43:27 steve
|
||||
* Add a sign-extension node.
|
||||
*
|
||||
* Revision 1.27 2005/05/09 00:36:58 steve
|
||||
* Force part base out of bounds if index is invalid.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue