Add thread word array, and add the instructions,
%add/wr, %cmp/wr, %load/wr, %mul/wr and %set/wr.
This commit is contained in:
parent
07a427bf28
commit
9a5a00f836
|
|
@ -16,7 +16,7 @@
|
|||
# 59 Temple Place - Suite 330
|
||||
# Boston, MA 02111-1307, USA
|
||||
#
|
||||
#ident "$Id: Makefile.in,v 1.41 2003/01/10 03:06:32 steve Exp $"
|
||||
#ident "$Id: Makefile.in,v 1.42 2003/01/25 23:48:05 steve Exp $"
|
||||
#
|
||||
#
|
||||
SHELL = /bin/sh
|
||||
|
|
@ -62,13 +62,14 @@ check: all
|
|||
./vvp -M../vpi $(srcdir)/examples/hello.vvp | grep 'Hello, World.'
|
||||
|
||||
V = vpi_modules.o vpi_callback.o vpi_const.o vpi_event.o vpi_iter.o vpi_mcd.o \
|
||||
vpi_priv.o vpi_scope.o vpi_signal.o vpi_tasks.o vpi_time.o vpi_memory.o \
|
||||
vpi_vthr_vector.o vpip_bin.o vpip_hex.o vpip_oct.o vpip_to_dec.o vvp_vpi.o
|
||||
vpi_priv.o vpi_scope.o vpi_real.o vpi_signal.o vpi_tasks.o vpi_time.o \
|
||||
vpi_memory.o vpi_vthr_vector.o vpip_bin.o vpip_hex.o vpip_oct.o \
|
||||
vpip_to_dec.o vvp_vpi.o
|
||||
|
||||
O = main.o parse.o parse_misc.o lexor.o arith.o bufif.o compile.o debug.o \
|
||||
functor.o fvectors.o npmos.o resolv.o symbols.o ufunc.o codes.o vthread.o \
|
||||
schedule.o statistics.o tables.o udp.o memory.o force.o event.o \
|
||||
logic.o delay.o $V
|
||||
logic.o delay.o words.o $V
|
||||
|
||||
ifeq (@WIN32@,yes)
|
||||
# Under Windows (mingw) I need to make the ivl.exe in two steps.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* $Id: README.txt,v 1.40 2002/03/18 00:19:34 steve Exp $
|
||||
* $Id: README.txt,v 1.41 2003/01/25 23:48:06 steve Exp $
|
||||
*/
|
||||
|
||||
VVP SIMULATION ENGINE
|
||||
|
|
@ -386,6 +386,21 @@ to trigger this event. Only one of the input events needs to trigger
|
|||
to make this one go.
|
||||
|
||||
|
||||
WORD STATEMENTS:
|
||||
|
||||
Verilog includes some scalered word types available to the programmer,
|
||||
including real variables, and possible extension types that the code
|
||||
generator can transparently use. Variables of these special types are
|
||||
declared with .word statements:
|
||||
|
||||
<label> .word <type>, "vpi name";
|
||||
|
||||
The <type> values supported are listed below. The vpi name is the base
|
||||
name given to the VPI object that is created.
|
||||
|
||||
real - represents a double precision real variable.
|
||||
|
||||
|
||||
RESOLVER STATEMENTS:
|
||||
|
||||
Resolver statements are strength-aware functors with 4 inputs, but
|
||||
|
|
|
|||
29
vvp/codes.h
29
vvp/codes.h
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __codes_H
|
||||
#define __codes_H
|
||||
/*
|
||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2001-2003 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
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: codes.h,v 1.54 2002/11/21 22:43:13 steve Exp $"
|
||||
#ident "$Id: codes.h,v 1.55 2003/01/25 23:48:06 steve Exp $"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -36,6 +36,7 @@ typedef bool (*vvp_code_fun)(vthread_t thr, vvp_code_t code);
|
|||
* access to the thread context.
|
||||
*/
|
||||
extern bool of_ADD(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_ADD_WR(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_ADDI(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_AND(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_ANDR(vthread_t thr, vvp_code_t code);
|
||||
|
|
@ -50,6 +51,7 @@ extern bool of_CASSIGN(vthread_t thr, vvp_code_t code);
|
|||
extern bool of_CMPIU(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_CMPS(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_CMPU(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_CMPWR(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_CMPX(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_CMPZ(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_DEASSIGN(vthread_t thr, vvp_code_t code);
|
||||
|
|
@ -76,10 +78,13 @@ extern bool of_LOAD(vthread_t thr, vvp_code_t code);
|
|||
extern bool of_LOAD_MEM(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_LOAD_NX(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_LOAD_VEC(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_LOAD_WR(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_LOAD_X(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_LOADI_WR(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_MOD(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_MOV(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_MUL(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_MUL_WR(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_MULI(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_NAND(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_NANDR(vthread_t thr, vvp_code_t code);
|
||||
|
|
@ -92,6 +97,7 @@ extern bool of_RELEASE(vthread_t thr, vvp_code_t code);
|
|||
extern bool of_SET(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_SET_MEM(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_SET_VEC(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_SET_WORDR(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_SET_X0(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_SHIFTL_I0(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_SHIFTR_I0(vthread_t thr, vvp_code_t code);
|
||||
|
|
@ -160,6 +166,10 @@ extern vvp_code_t codespace_index(vvp_cpoint_t ptr);
|
|||
|
||||
/*
|
||||
* $Log: codes.h,v $
|
||||
* Revision 1.55 2003/01/25 23:48:06 steve
|
||||
* Add thread word array, and add the instructions,
|
||||
* %add/wr, %cmp/wr, %load/wr, %mul/wr and %set/wr.
|
||||
*
|
||||
* Revision 1.54 2002/11/21 22:43:13 steve
|
||||
* %set/x0 instruction to support bounds checking.
|
||||
*
|
||||
|
|
@ -207,20 +217,5 @@ extern vvp_code_t codespace_index(vvp_cpoint_t ptr);
|
|||
*
|
||||
* Revision 1.39 2002/04/14 18:41:34 steve
|
||||
* Support signed integer division.
|
||||
*
|
||||
* Revision 1.38 2002/03/18 00:19:34 steve
|
||||
* Add the .ufunc statement.
|
||||
*
|
||||
* Revision 1.37 2001/11/07 03:34:42 steve
|
||||
* Use functor pointers where vvp_ipoint_t is unneeded.
|
||||
*
|
||||
* Revision 1.36 2001/11/01 03:00:19 steve
|
||||
* Add force/cassign/release/deassign support. (Stephan Boettcher)
|
||||
*
|
||||
* Revision 1.35 2001/10/16 01:26:54 steve
|
||||
* Add %div support (Anthony Bybell)
|
||||
*
|
||||
* Revision 1.34 2001/08/26 22:59:32 steve
|
||||
* Add the assign/x0 and set/x opcodes.
|
||||
*/
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2001-2003 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
|
||||
|
|
@ -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.147 2002/12/21 00:55:58 steve Exp $"
|
||||
#ident "$Id: compile.cc,v 1.148 2003/01/25 23:48:06 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "arith.h"
|
||||
|
|
@ -83,6 +83,7 @@ struct opcode_table_s {
|
|||
|
||||
const static struct opcode_table_s opcode_table[] = {
|
||||
{ "%add", of_ADD, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%add/wr", of_ADD_WR, 2, {OA_BIT1, OA_BIT2, OA_NONE} },
|
||||
{ "%addi", of_ADDI, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%and", of_AND, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%and/r", of_ANDR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
|
|
@ -96,6 +97,7 @@ const static struct opcode_table_s opcode_table[] = {
|
|||
{ "%cassign",of_CASSIGN,2, {OA_FUNC_PTR, OA_FUNC_PTR2,OA_NONE} },
|
||||
{ "%cmp/s", of_CMPS, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%cmp/u", of_CMPU, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%cmp/wr", of_CMPWR, 2, {OA_BIT1, OA_BIT2, OA_NONE} },
|
||||
{ "%cmp/x", of_CMPX, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%cmp/z", of_CMPZ, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%cmpi/u", of_CMPIU, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
|
|
@ -121,10 +123,13 @@ const static struct opcode_table_s opcode_table[] = {
|
|||
{ "%load/m", of_LOAD_MEM,2, {OA_BIT1, OA_MEM_PTR, OA_NONE} },
|
||||
{ "%load/nx",of_LOAD_NX,3, {OA_BIT1, OA_VPI_PTR, OA_BIT2} },
|
||||
{ "%load/v", of_LOAD_VEC,3, {OA_BIT1, OA_FUNC_PTR, OA_BIT2} },
|
||||
{ "%load/x", of_LOAD_X, 3, {OA_BIT1, OA_FUNC_PTR, OA_BIT2} },
|
||||
{ "%load/wr",of_LOAD_WR,2, {OA_BIT1, OA_VPI_PTR, OA_BIT2} },
|
||||
{ "%load/x", of_LOAD_X, 3, {OA_BIT1, OA_FUNC_PTR, OA_NONE} },
|
||||
{ "%loadi/wr",of_LOADI_WR,3,{OA_BIT1, OA_NUMBER, OA_BIT2} },
|
||||
{ "%mod", of_MOD, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%mov", of_MOV, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%mul", of_MUL, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%mul/wr", of_MUL_WR, 2, {OA_BIT1, OA_BIT2, OA_NONE} },
|
||||
{ "%muli", of_MULI, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%nand", of_NAND, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%nand/r", of_NANDR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
|
|
@ -137,6 +142,7 @@ const static struct opcode_table_s opcode_table[] = {
|
|||
{ "%set", of_SET, 2, {OA_FUNC_PTR, OA_BIT1, OA_NONE} },
|
||||
{ "%set/m", of_SET_MEM,2, {OA_MEM_PTR, OA_BIT1, OA_NONE} },
|
||||
{ "%set/v", of_SET_VEC,3, {OA_FUNC_PTR, OA_BIT1, OA_BIT2} },
|
||||
{ "%set/wr", of_SET_WORDR,2,{OA_VPI_PTR, OA_BIT1, OA_NONE} },
|
||||
{ "%set/x0", of_SET_X0, 3, {OA_FUNC_PTR, OA_BIT1, OA_BIT2} },
|
||||
{ "%shiftl/i0", of_SHIFTL_I0, 2, {OA_BIT1,OA_NUMBER, OA_NONE} },
|
||||
{ "%shiftr/i0", of_SHIFTR_I0, 2, {OA_BIT1,OA_NUMBER, OA_NONE} },
|
||||
|
|
@ -1493,6 +1499,10 @@ void compile_net(char*label, char*name, int msb, int lsb, bool signed_flag,
|
|||
|
||||
/*
|
||||
* $Log: compile.cc,v $
|
||||
* Revision 1.148 2003/01/25 23:48:06 steve
|
||||
* Add thread word array, and add the instructions,
|
||||
* %add/wr, %cmp/wr, %load/wr, %mul/wr and %set/wr.
|
||||
*
|
||||
* Revision 1.147 2002/12/21 00:55:58 steve
|
||||
* The $time system task returns the integer time
|
||||
* scaled to the local units. Change the internal
|
||||
|
|
@ -1538,67 +1548,5 @@ void compile_net(char*label, char*name, int msb, int lsb, bool signed_flag,
|
|||
*
|
||||
* Revision 1.134 2002/07/05 17:14:15 steve
|
||||
* Names of vpi objects allocated as vpip_strings.
|
||||
*
|
||||
* Revision 1.133 2002/07/05 04:40:59 steve
|
||||
* Symbol table uses more efficient key string allocator,
|
||||
* and remove all the symbol tables after compile is done.
|
||||
*
|
||||
* Revision 1.132 2002/07/05 02:50:58 steve
|
||||
* Remove the vpi object symbol table after compile.
|
||||
*
|
||||
* Revision 1.131 2002/06/21 04:58:55 steve
|
||||
* Add support for special integer vectors.
|
||||
*
|
||||
* Revision 1.130 2002/06/02 18:55:58 steve
|
||||
* Add %cmpi/u instruction.
|
||||
*
|
||||
* Revision 1.129 2002/05/31 20:04:22 steve
|
||||
* Add the %muli instruction.
|
||||
*
|
||||
* Revision 1.128 2002/05/29 16:29:34 steve
|
||||
* Add %addi, which is faster to simulate.
|
||||
*
|
||||
* Revision 1.127 2002/05/10 16:00:57 steve
|
||||
* Support scope iterate over vpiNet,vpiReg/vpiMemory.
|
||||
*
|
||||
* Revision 1.126 2002/05/07 04:15:43 steve
|
||||
* Fix uninitialized memory accesses.
|
||||
*
|
||||
* Revision 1.125 2002/04/21 22:29:49 steve
|
||||
* Add the assign/d instruction for computed delays.
|
||||
*
|
||||
* Revision 1.124 2002/04/14 18:41:34 steve
|
||||
* Support signed integer division.
|
||||
*
|
||||
* Revision 1.123 2002/04/14 02:56:19 steve
|
||||
* Support signed expressions through to VPI.
|
||||
*
|
||||
* Revision 1.122 2002/03/18 00:19:34 steve
|
||||
* Add the .ufunc statement.
|
||||
*
|
||||
* Revision 1.121 2002/03/08 05:41:45 steve
|
||||
* Debug code for write to constants.
|
||||
*
|
||||
* Revision 1.120 2002/01/11 05:21:47 steve
|
||||
* Magic stime object support.
|
||||
*
|
||||
* Revision 1.119 2002/01/06 03:15:13 steve
|
||||
* Support weak functor inputs.
|
||||
*
|
||||
* Revision 1.118 2002/01/03 04:19:02 steve
|
||||
* Add structural modulus support down to vvp.
|
||||
*
|
||||
* Revision 1.117 2001/12/15 02:11:51 steve
|
||||
* Give tri0 and tri1 their proper strengths.
|
||||
*
|
||||
* Revision 1.116 2001/12/15 01:54:38 steve
|
||||
* Support tri0 and tri1 resolvers.
|
||||
*
|
||||
* Revision 1.115 2001/12/06 03:31:24 steve
|
||||
* Support functor delays for gates and UDP devices.
|
||||
* (Stephan Boettcher)
|
||||
*
|
||||
* Revision 1.114 2001/11/07 03:34:42 steve
|
||||
* Use functor pointers where vvp_ipoint_t is unneeded.
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __compile_H
|
||||
#define __compile_H
|
||||
/*
|
||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2001-2003 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
|
||||
|
|
@ -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.46 2002/12/21 00:55:58 steve Exp $"
|
||||
#ident "$Id: compile.h,v 1.47 2003/01/25 23:48:06 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <stdio.h>
|
||||
|
|
@ -188,6 +188,11 @@ extern void compile_event(char*label, char*type,
|
|||
unsigned argc, struct symb_s*argv);
|
||||
extern void compile_named_event(char*label, char*type);
|
||||
|
||||
/*
|
||||
* Word declarations include a label, a type symbol, and a vpi name.
|
||||
*/
|
||||
extern void compile_word(char*label, char*type, char*name);
|
||||
|
||||
/*
|
||||
* A code statement is a label, an opcode and up to 3 operands. There
|
||||
* are a few lexical types that the parser recognizes of the operands,
|
||||
|
|
@ -252,6 +257,10 @@ extern void compile_net(char*label, char*name,
|
|||
|
||||
/*
|
||||
* $Log: compile.h,v $
|
||||
* Revision 1.47 2003/01/25 23:48:06 steve
|
||||
* Add thread word array, and add the instructions,
|
||||
* %add/wr, %cmp/wr, %load/wr, %mul/wr and %set/wr.
|
||||
*
|
||||
* Revision 1.46 2002/12/21 00:55:58 steve
|
||||
* The $time system task returns the integer time
|
||||
* scaled to the local units. Change the internal
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: lexor.lex,v 1.35 2002/12/21 00:55:58 steve Exp $"
|
||||
#ident "$Id: lexor.lex,v 1.36 2003/01/25 23:48:06 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "parse_misc.h"
|
||||
|
|
@ -105,6 +105,7 @@
|
|||
".var" { return K_VAR; }
|
||||
".var/s" { return K_VAR_S; }
|
||||
".var/i" { return K_VAR_I; /* integer */ }
|
||||
".word" { return K_WORD; }
|
||||
".udp" { return K_UDP; }
|
||||
".udp/c"(omb)? { return K_UDP_C; }
|
||||
".udp/s"(equ)? { return K_UDP_S; }
|
||||
|
|
@ -174,6 +175,10 @@ int yywrap()
|
|||
|
||||
/*
|
||||
* $Log: lexor.lex,v $
|
||||
* Revision 1.36 2003/01/25 23:48:06 steve
|
||||
* Add thread word array, and add the instructions,
|
||||
* %add/wr, %cmp/wr, %load/wr, %mul/wr and %set/wr.
|
||||
*
|
||||
* Revision 1.35 2002/12/21 00:55:58 steve
|
||||
* The $time system task returns the integer time
|
||||
* scaled to the local units. Change the internal
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* $Id: opcodes.txt,v 1.45 2002/11/21 22:43:13 steve Exp $
|
||||
* $Id: opcodes.txt,v 1.46 2003/01/25 23:48:06 steve Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
|
@ -30,6 +30,10 @@ sum.
|
|||
|
||||
See also the %sub instruction.
|
||||
|
||||
|
||||
* %add/wr <bit-l>, <bit-r>
|
||||
|
||||
|
||||
* %addi <bit-l>, <imm>, <wid>
|
||||
|
||||
This instruction adds the immediate value (no x or z bits) into the
|
||||
|
|
@ -155,6 +159,12 @@ The %cmp/u and %cmp/s differ only in the handling of the lt bit. The
|
|||
compare. In either case, if either operand constains x or z, then lt
|
||||
bit gets the x value.
|
||||
|
||||
|
||||
* %cmp/wr <bit-l>, <bit-r>
|
||||
|
||||
[compare real values.]
|
||||
|
||||
|
||||
* %cmp/z <bit-l>, <bit-r>, <wid>
|
||||
* %cmp/x <bit-l>, <bit-r>, <wid>
|
||||
|
||||
|
|
@ -325,6 +335,10 @@ This instruction load a value from a .net object bit. Since .net
|
|||
objects don't really exist (they are only named indirection into the
|
||||
netlist) this instruction indexes into the .net list of bits.
|
||||
|
||||
* %load/wr <bit>, <vpi-label>
|
||||
|
||||
This instruction reads a real value from the vpi-like object to a word
|
||||
register.
|
||||
|
||||
* %load/x <bit>, <functor-label>, <idx>
|
||||
|
||||
|
|
@ -334,6 +348,15 @@ bit is pulled from the addressed functor and loaded into the
|
|||
destination bit. This function does not do any bounds checking.
|
||||
|
||||
|
||||
* %loadi/wr <bit>, <mant>, <exp>
|
||||
|
||||
This opcode loads an immediate value, floating point, into the word
|
||||
register selected by <bit>. The mantissa is an unsigned integer value,
|
||||
up to 32 bits, that multiplied by 2**(<exp>-0x1000) to make a real
|
||||
value. The sign bit is OR-ed into the <exp> value at bit 0x2000, and
|
||||
is removed from the <exp> before calculating the real value.
|
||||
|
||||
|
||||
* %mod <bit-l>, <bit-r>, <wid>
|
||||
|
||||
This instruction calculates the modulus %r of the left operand, and
|
||||
|
|
@ -359,6 +382,12 @@ are x or z, the result is x. Otherwise, the result is the arithmetic
|
|||
product.
|
||||
|
||||
|
||||
* %mul/wr <bit-l>, <bit-r>
|
||||
|
||||
This opcode multiplies two real words together. The result replaces
|
||||
the left operand.
|
||||
|
||||
|
||||
* %muli <bit-l>, <imm>, <wid>
|
||||
|
||||
This instruction is the same as %mul, but the second operand is an
|
||||
|
|
@ -459,6 +488,10 @@ address zero is the LSB of the first memory word. This instruction
|
|||
sets only a single bit.
|
||||
|
||||
|
||||
* %set/wr <vpi-label>, <bit>
|
||||
|
||||
This instruction writes a real word to the specified VPI-like object.
|
||||
|
||||
* %set/x0 <var-label>, <bit>, <top>
|
||||
|
||||
This sets the bit of a variable functor, the address calculated by
|
||||
|
|
|
|||
13
vvp/parse.y
13
vvp/parse.y
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: parse.y,v 1.48 2002/12/21 00:55:58 steve Exp $"
|
||||
#ident "$Id: parse.y,v 1.49 2003/01/25 23:48:06 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "parse_misc.h"
|
||||
|
|
@ -63,7 +63,7 @@ extern FILE*yyin;
|
|||
%token K_RESOLV K_SCOPE K_SHIFTL K_SHIFTR K_THREAD K_TIMESCALE K_UFUNC
|
||||
%token K_UDP K_UDP_C K_UDP_S
|
||||
%token K_MEM K_MEM_P K_MEM_I
|
||||
%token K_FORCE
|
||||
%token K_FORCE K_WORD
|
||||
%token K_VAR K_VAR_S K_VAR_I K_vpi_call K_vpi_func K_disable K_fork
|
||||
%token K_vpi_module K_vpi_time_precision
|
||||
|
||||
|
|
@ -250,6 +250,11 @@ statement
|
|||
{ compile_event($1, 0, $3.cnt, $3.vect); }
|
||||
|
||||
|
||||
/* match word statements. */
|
||||
|
||||
| T_LABEL K_WORD T_SYMBOL ',' T_STRING ';'
|
||||
{ compile_word($1, $3, $5); }
|
||||
|
||||
/* Instructions may have a label, and have zero or more
|
||||
operands. The meaning of and restrictions on the operands depends
|
||||
on the specific instruction. */
|
||||
|
|
@ -559,6 +564,10 @@ int compile_design(const char*path)
|
|||
|
||||
/*
|
||||
* $Log: parse.y,v $
|
||||
* Revision 1.49 2003/01/25 23:48:06 steve
|
||||
* Add thread word array, and add the instructions,
|
||||
* %add/wr, %cmp/wr, %load/wr, %mul/wr and %set/wr.
|
||||
*
|
||||
* Revision 1.48 2002/12/21 00:55:58 steve
|
||||
* The $time system task returns the integer time
|
||||
* scaled to the local units. Change the internal
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __vpi_priv_H
|
||||
#define __vpi_priv_H
|
||||
/*
|
||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2001-2003 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
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: vpi_priv.h,v 1.42 2003/01/09 04:09:44 steve Exp $"
|
||||
#ident "$Id: vpi_priv.h,v 1.43 2003/01/25 23:48:06 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_user.h"
|
||||
|
|
@ -211,6 +211,11 @@ extern void vpip_run_named_event_callbacks(vpiHandle ref);
|
|||
|
||||
extern vpiHandle vpip_make_memory(vvp_memory_t mem);
|
||||
|
||||
/*
|
||||
* These are the various variable types.
|
||||
*/
|
||||
extern vpiHandle vpip_make_real_var(const char*name);
|
||||
|
||||
/*
|
||||
* When a loaded VPI module announces a system task/function, one
|
||||
* __vpiUserSystf object is created to hold the definition of that
|
||||
|
|
@ -385,6 +390,10 @@ extern char *need_result_buf(unsigned cnt, vpi_rbuf_t type);
|
|||
|
||||
/*
|
||||
* $Log: vpi_priv.h,v $
|
||||
* Revision 1.43 2003/01/25 23:48:06 steve
|
||||
* Add thread word array, and add the instructions,
|
||||
* %add/wr, %cmp/wr, %load/wr, %mul/wr and %set/wr.
|
||||
*
|
||||
* Revision 1.42 2003/01/09 04:09:44 steve
|
||||
* Add vpi_put_userdata
|
||||
*
|
||||
|
|
@ -431,64 +440,5 @@ extern char *need_result_buf(unsigned cnt, vpi_rbuf_t type);
|
|||
* Support specified times in cbReadOnlySync, and
|
||||
* add support for cbReadWriteSync.
|
||||
* Keep simulation time in a 64bit number.
|
||||
*
|
||||
* Revision 1.30 2002/04/14 03:53:20 steve
|
||||
* Allow signed constant vectors for call_vpi parameters.
|
||||
*
|
||||
* Revision 1.29 2002/04/14 02:56:19 steve
|
||||
* Support signed expressions through to VPI.
|
||||
*
|
||||
* Revision 1.28 2002/02/03 01:01:51 steve
|
||||
* Use Larrys bits-to-decimal-string code.
|
||||
*
|
||||
* Revision 1.27 2002/01/31 04:28:17 steve
|
||||
* Full support for $readmem ranges (Tom Verbeure)
|
||||
*
|
||||
* Revision 1.26 2002/01/06 17:50:50 steve
|
||||
* Support scope for functors. (Stephan Boettcher)
|
||||
*
|
||||
* Revision 1.25 2002/01/06 00:48:39 steve
|
||||
* VPI access to root module scopes.
|
||||
*
|
||||
* Revision 1.24 2001/10/31 04:27:47 steve
|
||||
* Rewrite the functor type to have fewer functor modes,
|
||||
* and use objects to manage the different types.
|
||||
* (Stephan Boettcher)
|
||||
*
|
||||
* Revision 1.23 2001/10/15 01:49:50 steve
|
||||
* Support getting scope of scope, and scope of signals.
|
||||
*
|
||||
* Revision 1.22 2001/08/08 01:05:06 steve
|
||||
* Initial implementation of vvp_fvectors.
|
||||
* (Stephan Boettcher)
|
||||
*
|
||||
* Revision 1.21 2001/07/30 02:44:05 steve
|
||||
* Cleanup defines and types for mingw compile.
|
||||
*
|
||||
* Revision 1.20 2001/07/26 03:13:51 steve
|
||||
* Make the -M flag add module search paths.
|
||||
*
|
||||
* Revision 1.19 2001/07/11 02:27:21 steve
|
||||
* Add support for REadOnlySync and monitors.
|
||||
*
|
||||
* Revision 1.18 2001/06/30 23:03:17 steve
|
||||
* support fast programming by only writing the bits
|
||||
* that are listed in the input file.
|
||||
*
|
||||
* Revision 1.17 2001/06/21 22:54:12 steve
|
||||
* Support cbValueChange callbacks.
|
||||
*
|
||||
* Revision 1.16 2001/05/20 00:46:12 steve
|
||||
* Add support for system function calls.
|
||||
*
|
||||
* Revision 1.15 2001/05/10 00:26:53 steve
|
||||
* VVP support for memories in expressions,
|
||||
* including general support for thread bit
|
||||
* vectors as system task parameters.
|
||||
* (Stephan Boettcher)
|
||||
*
|
||||
* Revision 1.14 2001/05/08 23:59:33 steve
|
||||
* Add ivl and vvp.tgt support for memories in
|
||||
* expressions and l-values. (Stephan Boettcher)
|
||||
*/
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* Copyright (c) 2003 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: vpi_real.cc,v 1.1 2003/01/25 23:48:06 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
#ifdef HAVE_MALLOC_H
|
||||
# include <malloc.h>
|
||||
#endif
|
||||
# include <assert.h>
|
||||
|
||||
|
||||
struct __vpiRealVar {
|
||||
struct __vpiHandle base;
|
||||
const char*name;
|
||||
double value;
|
||||
};
|
||||
|
||||
static void real_var_get_value(vpiHandle ref, s_vpi_value*vp)
|
||||
{
|
||||
assert(ref->vpi_type->type_code == vpiRealVar);
|
||||
|
||||
struct __vpiRealVar*rfp = (struct __vpiRealVar*)ref;
|
||||
|
||||
switch (vp->format) {
|
||||
case vpiObjTypeVal:
|
||||
vp->format = vpiRealVal;
|
||||
case vpiRealVal:
|
||||
vp->value.real = rfp->value;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "ERROR: Unsupported format code: %d\n",
|
||||
vp->format);
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
static vpiHandle real_var_put_value(vpiHandle ref, p_vpi_value vp,
|
||||
p_vpi_time, int)
|
||||
{
|
||||
assert(ref->vpi_type->type_code == vpiRealVar);
|
||||
|
||||
struct __vpiRealVar*rfp = (struct __vpiRealVar*)ref;
|
||||
|
||||
assert(vp->format == vpiRealVal);
|
||||
rfp->value = vp->value.real;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int real_var_free_object(vpiHandle)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct __vpirt vpip_real_var_rt = {
|
||||
vpiRealVar,
|
||||
|
||||
0,
|
||||
0,
|
||||
&real_var_get_value,
|
||||
&real_var_put_value,
|
||||
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
||||
real_var_free_object
|
||||
};
|
||||
|
||||
vpiHandle vpip_make_real_var(const char*name)
|
||||
{
|
||||
struct __vpiRealVar*obj = (struct __vpiRealVar*)
|
||||
malloc(sizeof(struct __vpiRealVar));
|
||||
|
||||
obj->base.vpi_type = &vpip_real_var_rt;
|
||||
obj->name = vpip_string(name);
|
||||
obj->value = 0.0;
|
||||
|
||||
return &obj->base;
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: vpi_real.cc,v $
|
||||
* Revision 1.1 2003/01/25 23:48:06 steve
|
||||
* Add thread word array, and add the instructions,
|
||||
* %add/wr, %cmp/wr, %load/wr, %mul/wr and %set/wr.
|
||||
*
|
||||
*/
|
||||
|
||||
266
vvp/vthread.cc
266
vvp/vthread.cc
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001-2002 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2001-2003 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
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: vthread.cc,v 1.96 2003/01/06 23:57:26 steve Exp $"
|
||||
#ident "$Id: vthread.cc,v 1.97 2003/01/25 23:48:06 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vthread.h"
|
||||
|
|
@ -34,6 +34,7 @@
|
|||
# include <stdlib.h>
|
||||
# include <limits.h>
|
||||
# include <string.h>
|
||||
# include <math.h>
|
||||
# include <assert.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
@ -96,7 +97,13 @@ struct vthread_s {
|
|||
unsigned long pc;
|
||||
/* These hold the private thread bits. */
|
||||
unsigned long *bits;
|
||||
long index[4];
|
||||
|
||||
/* These are the word registers. */
|
||||
union {
|
||||
long w_int;
|
||||
double w_real;
|
||||
} words[16];
|
||||
|
||||
unsigned nbits :16;
|
||||
/* My parent sets this when it wants me to wake it up. */
|
||||
unsigned schedule_parent_on_end :1;
|
||||
|
|
@ -423,6 +430,14 @@ bool of_ADD(vthread_t thr, vvp_code_t cp)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool of_ADD_WR(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
double l = thr->words[cp->bit_idx[0]].w_real;
|
||||
double r = thr->words[cp->bit_idx[1]].w_real;
|
||||
thr->words[cp->bit_idx[0]].w_real = l + r;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is %addi, add-immediate. The first value is a vector, the
|
||||
* second value is the immediate value in the bin_idx[1] position. The
|
||||
|
|
@ -492,7 +507,7 @@ bool of_ASSIGN_D(vthread_t thr, vvp_code_t cp)
|
|||
{
|
||||
assert(cp->bit_idx[0] < 4);
|
||||
unsigned char bit_val = thr_get_bit(thr, cp->bit_idx[1]);
|
||||
schedule_assign(cp->iptr, bit_val, thr->index[cp->bit_idx[0]]);
|
||||
schedule_assign(cp->iptr, bit_val, thr->words[cp->bit_idx[0]].w_int);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -502,7 +517,7 @@ bool of_ASSIGN_D(vthread_t thr, vvp_code_t cp)
|
|||
*/
|
||||
bool of_ASSIGN_V0(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
unsigned wid = thr->index[0];
|
||||
unsigned wid = thr->words[0].w_int;
|
||||
assert(wid > 0);
|
||||
assert(wid < 0x10000);
|
||||
|
||||
|
|
@ -525,7 +540,7 @@ bool of_ASSIGN_V0(vthread_t thr, vvp_code_t cp)
|
|||
bool of_ASSIGN_X0(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
unsigned char bit_val = thr_get_bit(thr, cp->bit_idx[1]);
|
||||
vvp_ipoint_t itmp = ipoint_index(cp->iptr, thr->index[0]);
|
||||
vvp_ipoint_t itmp = ipoint_index(cp->iptr, thr->words[0].w_int);
|
||||
schedule_assign(itmp, bit_val, cp->bit_idx[0]);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -533,7 +548,7 @@ bool of_ASSIGN_X0(vthread_t thr, vvp_code_t cp)
|
|||
bool of_ASSIGN_MEM(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
unsigned char bit_val = thr_get_bit(thr, cp->bit_idx[1]);
|
||||
schedule_memory(cp->mem, thr->index[3], bit_val, cp->bit_idx[0]);
|
||||
schedule_memory(cp->mem, thr->words[3].w_int, bit_val, cp->bit_idx[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -752,6 +767,20 @@ bool of_CMPX(vthread_t thr, vvp_code_t cp)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool of_CMPWR(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
double l = thr->words[cp->bit_idx[0]].w_real;
|
||||
double r = thr->words[cp->bit_idx[1]].w_real;
|
||||
|
||||
unsigned eq = (l == r)? 1 : 0;
|
||||
unsigned lt = (l < r)? 1 : 0;
|
||||
|
||||
thr_put_bit(thr, 4, eq);
|
||||
thr_put_bit(thr, 5, lt);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool of_CMPZ(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
unsigned eq = 1;
|
||||
|
|
@ -789,7 +818,7 @@ bool of_DELAYX(vthread_t thr, vvp_code_t cp)
|
|||
unsigned long delay;
|
||||
|
||||
assert(cp->number < 4);
|
||||
delay = thr->index[cp->number];
|
||||
delay = thr->words[cp->number].w_int;
|
||||
schedule_vthread(thr, delay);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1301,25 +1330,25 @@ bool of_INV(vthread_t thr, vvp_code_t cp)
|
|||
|
||||
bool of_IX_ADD(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
thr->index[cp->bit_idx[0] & 3] += cp->number;
|
||||
thr->words[cp->bit_idx[0] & 3].w_int += cp->number;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool of_IX_SUB(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
thr->index[cp->bit_idx[0] & 3] -= cp->number;
|
||||
thr->words[cp->bit_idx[0] & 3].w_int -= cp->number;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool of_IX_MUL(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
thr->index[cp->bit_idx[0] & 3] *= cp->number;
|
||||
thr->words[cp->bit_idx[0] & 3].w_int *= cp->number;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool of_IX_LOAD(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
thr->index[cp->bit_idx[0] & 3] = cp->number;
|
||||
thr->words[cp->bit_idx[0] & 3].w_int = cp->number;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1350,7 +1379,7 @@ bool of_IX_GET(vthread_t thr, vvp_code_t cp)
|
|||
}
|
||||
v |= vv << i;
|
||||
}
|
||||
thr->index[cp->bit_idx[0] & 3] = v;
|
||||
thr->words[cp->bit_idx[0] & 3].w_int = v;
|
||||
/* Set bit 4 as a flag if the input is unknown. */
|
||||
thr_put_bit(thr, 4, unknown_flag? 1 : 0);
|
||||
return true;
|
||||
|
|
@ -1425,7 +1454,7 @@ bool of_LOAD(vthread_t thr, vvp_code_t cp)
|
|||
bool of_LOAD_MEM(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
assert(cp->bit_idx[0] >= 4);
|
||||
unsigned char val = memory_get(cp->mem, thr->index[3]);
|
||||
unsigned char val = memory_get(cp->mem, thr->words[3].w_int);
|
||||
thr_put_bit(thr, cp->bit_idx[0], val);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1442,7 +1471,7 @@ bool of_LOAD_NX(vthread_t thr, vvp_code_t cp)
|
|||
struct __vpiSignal*sig =
|
||||
reinterpret_cast<struct __vpiSignal*>(cp->handle);
|
||||
|
||||
unsigned idx = thr->index[cp->bit_idx[1]];
|
||||
unsigned idx = thr->words[cp->bit_idx[1]].w_int;
|
||||
|
||||
vvp_ipoint_t ptr = vvp_fvector_get(sig->bits, idx);
|
||||
thr_put_bit(thr, cp->bit_idx[0], functor_get(ptr));
|
||||
|
|
@ -1464,16 +1493,43 @@ bool of_LOAD_VEC(vthread_t thr, vvp_code_t cp)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool of_LOAD_WR(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
struct __vpiHandle*tmp = cp->handle;
|
||||
t_vpi_value val;
|
||||
|
||||
val.format = vpiRealVal;
|
||||
vpi_get_value(tmp, &val);
|
||||
|
||||
thr->words[cp->bit_idx[0]].w_real = val.value.real;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool of_LOAD_X(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
assert(cp->bit_idx[0] >= 4);
|
||||
assert(cp->bit_idx[1] < 4);
|
||||
|
||||
vvp_ipoint_t ptr = ipoint_index(cp->iptr, thr->index[cp->bit_idx[1]]);
|
||||
vvp_ipoint_t ptr = ipoint_index(cp->iptr, thr->words[cp->bit_idx[1]].w_int);
|
||||
thr_put_bit(thr, cp->bit_idx[0], functor_get(ptr));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool of_LOADI_WR(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
unsigned idx = cp->bit_idx[0];
|
||||
double mant = cp->number;
|
||||
int exp = cp->bit_idx[1];
|
||||
double sign = (exp & 0x2000)? -1.0 : 1.0;
|
||||
|
||||
exp &= 0x1fff;
|
||||
|
||||
mant = sign * ldexp(mant, exp - 0x1000);
|
||||
thr->words[idx].w_real = mant;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool of_MOD(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
assert(cp->bit_idx[0] >= 4);
|
||||
|
|
@ -1813,6 +1869,14 @@ bool of_MUL(vthread_t thr, vvp_code_t cp)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool of_MUL_WR(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
double l = thr->words[cp->bit_idx[0]].w_real;
|
||||
double r = thr->words[cp->bit_idx[1]].w_real;
|
||||
thr->words[cp->bit_idx[0]].w_real = l * r;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool of_MULI(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
assert(cp->bit_idx[0] >= 4);
|
||||
|
|
@ -2164,7 +2228,7 @@ bool of_SET(vthread_t thr, vvp_code_t cp)
|
|||
bool of_SET_MEM(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
unsigned char val = thr_get_bit(thr, cp->bit_idx[0]);
|
||||
memory_set(cp->mem, thr->index[3], val);
|
||||
memory_set(cp->mem, thr->words[3].w_int, val);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2192,6 +2256,18 @@ bool of_SET_VEC(vthread_t thr, vvp_code_t cp)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool of_SET_WORDR(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
struct __vpiHandle*tmp = cp->handle;
|
||||
t_vpi_value val;
|
||||
|
||||
val.format = vpiRealVal;
|
||||
val.value.real = thr->words[cp->bit_idx[0]].w_real;
|
||||
vpi_put_value(tmp, &val, 0, vpiNoDelay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Implement the %set/x instruction:
|
||||
*
|
||||
|
|
@ -2203,7 +2279,7 @@ bool of_SET_VEC(vthread_t thr, vvp_code_t cp)
|
|||
bool of_SET_X0(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
unsigned char bit_val = thr_get_bit(thr, cp->bit_idx[0]);
|
||||
long idx = thr->index[0];
|
||||
long idx = thr->words[0].w_int;
|
||||
|
||||
/* If idx < 0, then the index value is probably generated from
|
||||
an undefined value. At any rate, this is defined to have no
|
||||
|
|
@ -2228,7 +2304,7 @@ bool of_SHIFTL_I0(vthread_t thr, vvp_code_t cp)
|
|||
{
|
||||
unsigned base = cp->bit_idx[0];
|
||||
unsigned wid = cp->number;
|
||||
unsigned long shift = thr->index[0];
|
||||
unsigned long shift = thr->words[0].w_int;
|
||||
|
||||
assert(base >= 4);
|
||||
|
||||
|
|
@ -2255,7 +2331,7 @@ bool of_SHIFTR_I0(vthread_t thr, vvp_code_t cp)
|
|||
{
|
||||
unsigned base = cp->bit_idx[0];
|
||||
unsigned wid = cp->number;
|
||||
unsigned long shift = thr->index[0];
|
||||
unsigned long shift = thr->words[0].w_int;
|
||||
|
||||
if (shift >= wid) {
|
||||
for (unsigned idx = 0 ; idx < wid ; idx += 1)
|
||||
|
|
@ -2505,6 +2581,10 @@ bool of_CALL_UFUNC(vthread_t thr, vvp_code_t cp)
|
|||
|
||||
/*
|
||||
* $Log: vthread.cc,v $
|
||||
* Revision 1.97 2003/01/25 23:48:06 steve
|
||||
* Add thread word array, and add the instructions,
|
||||
* %add/wr, %cmp/wr, %load/wr, %mul/wr and %set/wr.
|
||||
*
|
||||
* Revision 1.96 2003/01/06 23:57:26 steve
|
||||
* Schedule wait lists of threads as a single event,
|
||||
* to save on events. Also, improve efficiency of
|
||||
|
|
@ -2531,151 +2611,5 @@ bool of_CALL_UFUNC(vthread_t thr, vvp_code_t cp)
|
|||
*
|
||||
* Revision 1.89 2002/09/21 23:47:30 steve
|
||||
* Remove some now useless asserts.
|
||||
*
|
||||
* Revision 1.88 2002/09/21 04:55:00 steve
|
||||
* Fix disable in arbitrary fork/join situations.
|
||||
*
|
||||
* Revision 1.87 2002/09/20 03:59:34 steve
|
||||
* disable threads with children.
|
||||
*
|
||||
* Revision 1.86 2002/09/18 04:29:55 steve
|
||||
* Add support for binary NOR operator.
|
||||
*
|
||||
* Revision 1.85 2002/09/12 15:49:43 steve
|
||||
* Add support for binary nand operator.
|
||||
*
|
||||
* Revision 1.84 2002/08/28 18:38:07 steve
|
||||
* Add the %subi instruction, and use it where possible.
|
||||
*
|
||||
* Revision 1.83 2002/08/28 17:15:06 steve
|
||||
* Add the %load/nx opcode to index vpi nets.
|
||||
*
|
||||
* Revision 1.82 2002/08/27 05:39:57 steve
|
||||
* Fix l-value indexing of memories and vectors so that
|
||||
* an unknown (x) index causes so cell to be addresses.
|
||||
*
|
||||
* Fix tangling of label identifiers in the fork-join
|
||||
* code generator.
|
||||
*
|
||||
* Revision 1.81 2002/08/22 03:38:40 steve
|
||||
* Fix behavioral eval of x?a:b expressions.
|
||||
*
|
||||
* Revision 1.80 2002/08/18 01:05:50 steve
|
||||
* x in index values leads to 0.
|
||||
*
|
||||
* Revision 1.79 2002/08/12 01:35:09 steve
|
||||
* conditional ident string using autoconfig.
|
||||
*
|
||||
* Revision 1.78 2002/06/02 18:55:58 steve
|
||||
* Add %cmpi/u instruction.
|
||||
*
|
||||
* Revision 1.77 2002/05/31 20:04:22 steve
|
||||
* Add the %muli instruction.
|
||||
*
|
||||
* Revision 1.76 2002/05/31 04:09:58 steve
|
||||
* Slight improvement in %mov performance.
|
||||
*
|
||||
* Revision 1.75 2002/05/31 00:05:49 steve
|
||||
* Word oriented bit storage.
|
||||
*
|
||||
* Revision 1.74 2002/05/29 16:29:34 steve
|
||||
* Add %addi, which is faster to simulate.
|
||||
*
|
||||
* Revision 1.73 2002/05/27 00:53:10 steve
|
||||
* Able to disable thread self.
|
||||
*
|
||||
* Revision 1.72 2002/05/24 04:55:13 steve
|
||||
* Detect long division by zero.
|
||||
*
|
||||
* Revision 1.71 2002/05/19 05:18:16 steve
|
||||
* Add callbacks for vpiNamedEvent objects.
|
||||
*
|
||||
* Revision 1.70 2002/05/12 23:44:41 steve
|
||||
* task calls and forks push the thread event in the queue.
|
||||
*
|
||||
* Revision 1.69 2002/04/21 22:29:49 steve
|
||||
* Add the assign/d instruction for computed delays.
|
||||
*
|
||||
* Revision 1.68 2002/04/14 18:41:34 steve
|
||||
* Support signed integer division.
|
||||
*
|
||||
* Revision 1.67 2002/03/18 00:19:34 steve
|
||||
* Add the .ufunc statement.
|
||||
*
|
||||
* Revision 1.66 2002/01/26 02:08:07 steve
|
||||
* Handle x in l-value of set/x
|
||||
*
|
||||
* Revision 1.65 2001/12/31 00:01:16 steve
|
||||
* Account for negatives in cmp/s
|
||||
*
|
||||
* Revision 1.64 2001/11/06 03:07:22 steve
|
||||
* Code rearrange. (Stephan Boettcher)
|
||||
*
|
||||
* Revision 1.63 2001/11/01 03:00:20 steve
|
||||
* Add force/cassign/release/deassign support. (Stephan Boettcher)
|
||||
*
|
||||
* Revision 1.62 2001/10/31 04:27:47 steve
|
||||
* Rewrite the functor type to have fewer functor modes,
|
||||
* and use objects to manage the different types.
|
||||
* (Stephan Boettcher)
|
||||
*
|
||||
* Revision 1.61 2001/10/25 04:19:53 steve
|
||||
* VPI support for callback to return values.
|
||||
*
|
||||
* Revision 1.60 2001/10/23 03:49:13 steve
|
||||
* Fix carry between works for %add instruction.
|
||||
*
|
||||
* Revision 1.59 2001/10/20 23:20:32 steve
|
||||
* Catch and X division by 0.
|
||||
*
|
||||
* Revision 1.58 2001/10/16 01:26:55 steve
|
||||
* Add %div support (Anthony Bybell)
|
||||
*
|
||||
* Revision 1.57 2001/10/14 17:36:19 steve
|
||||
* Forgot to propagate carry.
|
||||
*
|
||||
* Revision 1.56 2001/10/14 16:36:43 steve
|
||||
* Very wide multiplication (Anthony Bybell)
|
||||
*
|
||||
* Revision 1.55 2001/09/15 18:27:05 steve
|
||||
* Make configure detect malloc.h
|
||||
*
|
||||
* Revision 1.54 2001/09/07 23:29:28 steve
|
||||
* Redo of_SUBU in a more obvious algorithm, that
|
||||
* is not significantly slower. Also, clean up the
|
||||
* implementation of %mov from a constant.
|
||||
*
|
||||
* Fix initial clearing of vector by vector_to_array
|
||||
*
|
||||
* Revision 1.53 2001/08/26 22:59:32 steve
|
||||
* Add the assign/x0 and set/x opcodes.
|
||||
*
|
||||
* Revision 1.52 2001/08/08 00:53:50 steve
|
||||
* signed/unsigned warnings?
|
||||
*
|
||||
* Revision 1.51 2001/07/22 00:04:50 steve
|
||||
* Add the load/x instruction for bit selects.
|
||||
*
|
||||
* Revision 1.50 2001/07/20 04:57:00 steve
|
||||
* Fix of_END when a middle thread ends.
|
||||
*
|
||||
* Revision 1.49 2001/07/19 04:40:55 steve
|
||||
* Add support for the delayx opcode.
|
||||
*
|
||||
* Revision 1.48 2001/07/04 04:57:10 steve
|
||||
* Relax limit on behavioral subtraction.
|
||||
*
|
||||
* Revision 1.47 2001/06/30 21:07:26 steve
|
||||
* Support non-const right shift (unsigned).
|
||||
*
|
||||
* Revision 1.46 2001/06/23 18:26:26 steve
|
||||
* Add the %shiftl/i0 instruction.
|
||||
*
|
||||
* Revision 1.45 2001/06/22 00:03:05 steve
|
||||
* Infinitely wide behavioral add.
|
||||
*
|
||||
* Revision 1.44 2001/06/18 01:09:32 steve
|
||||
* More behavioral unary reduction operators.
|
||||
* (Stephan Boettcher)
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2003 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: words.cc,v 1.1 2003/01/25 23:48:06 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "compile.h"
|
||||
# include "vpi_priv.h"
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
#ifdef HAVE_MALLOC_H
|
||||
# include <malloc.h>
|
||||
#endif
|
||||
# include <assert.h>
|
||||
|
||||
|
||||
void compile_word(char*label, char*type, char*name)
|
||||
{
|
||||
assert(strcmp(type, "real") == 0);
|
||||
free(type);
|
||||
|
||||
vpiHandle obj = vpip_make_real_var(name);
|
||||
free(name);
|
||||
|
||||
compile_vpi_symbol(label, obj);
|
||||
free(label);
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: words.cc,v $
|
||||
* Revision 1.1 2003/01/25 23:48:06 steve
|
||||
* Add thread word array, and add the instructions,
|
||||
* %add/wr, %cmp/wr, %load/wr, %mul/wr and %set/wr.
|
||||
*
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue