Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #48053

Re: Software for MISC M17

From Jan Coombs <jenfhaomndgfwutc@murmic.plus.com>
Newsgroups comp.lang.forth
Subject Re: Software for MISC M17
Date 2016-06-12 13:07 +0100
Organization A noiseless patient Spider
Message-ID <20160612130701.238bd615@HP-6550b> (permalink)
References (2 earlier) <nj4d2p$n4q$1@dont-email.me> <20160607110000.6aeb3847@HP-6550b> <nj6qvc$ja6$1@dont-email.me> <20160611224558.2586bc4e@HP-6550b> <nji3d8$8gh$1@dont-email.me>

Show all headers | View raw


On Sat, 11 Jun 2016 17:29:58 -0500
Cecil Bayona <cbayona@cbayona.com> wrote:

> How easy is to use a tool like MyHDL to convert the machine
> definition Python files to HDL? I briefly have looked at
> Python and it looks easy to use compared to VHDL, with the
> proviso that I have not looked at Python in detail. I've
> ordered several books on Python including some Kindle versions.

Once python and myhdl are installed (see myhdl.org) the script
below defines the logic, runs the simulation, and exports the
VHDL and Verilog for logic chip synthesis. 

Jan Coombs
-- 


"""         ep16_Stack_60col.py

2016-06-12 jc version with width reduced to 60 columns
"""

from myhdl import *


def Stack(popData, pushData,pop,push,clk, lg2dpth):
  ''' build stack (output, inputs, constant)'''
  
  # derive data path width, define memory array & pointers
  dpw = len(pushData)  

  stackmem = \
    [Signal(intbv(0)[dpw:]) for i in range(2**lg2dpth)]

  sp, spDecd, spIncd = \
    [Signal(modbv(0)[lg2dpth:]) for i in range(3)] 
  
  @always_comb  
  def stkIncDecLogic():
    ''' calc next pointer values '''
    spDecd.next = sp - 1 
    spIncd.next = sp + 1 

  @always_comb 
  def stackReadLogic():
    ''' read top of stack '''
    popData.next = stackmem[sp]
         
  @always(clk.posedge) 
  def stackWriteLogic():
    ''' action push or pop '''
    if push: 
      stackmem[spIncd].next = pushData;
      sp.next = spIncd 
    elif pop:
      sp.next = spDecd
        
  return stkIncDecLogic, stackReadLogic, stackWriteLogic
  # or,  return instances() 


# Outline Testing
# ---------------

# set constants
width=16
lg2dpth=3  # use 3 for 8 item stack

# create interface signals
popData = Signal(intbv(0)[width:])
pushData = Signal(intbv(0)[width:])
clk, pop, push = [Signal(bool()) for ii in range(3)]


def testStack():
  ''' test stack functions '''

  dut = Stack(popData, pushData,pop,push,clk, lg2dpth)
  
  @instance
  def check():
    ''' test framework '''
    push.next = 1
    for i in range(1,5):
      pushData.next = i
      yield delay(10)
      clk.next = 1
      yield delay(10)
      clk.next = 0
    push.next = 0
    
    pop.next = 1
    for i in range(4,0,-1):
      yield delay(10)
      #print i, popData  # debug check
      assert i==popData  # report error, kill job
      yield delay(10)
      clk.next = 1
      yield delay(10)
      clk.next = 0
    pop.next = 0
 
    print "ep16_Stack - test passed "  # for unbelievers
    
  return dut, check


def simulate(timesteps):
  ''' run simulator, convert to Verilog and VHDL '''
  toVerilog(Stack, popData, pushData,pop,push,clk, lg2dpth)
  toVHDL(Stack, popData, pushData,pop,push,clk, lg2dpth)
  sim = Simulation(testStack())
  sim.run(timesteps)

simulate(250)

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Software for MISC M17 Cecil Bayona <cbayona@cbayona.com> - 2016-05-29 17:38 -0500
  Re: Software for MISC M17 Richard Owlett <rowlett@cloud85.net> - 2016-05-30 09:45 -0500
    Re: Software for MISC M17 Cecil Bayona <cbayona@cbayona.com> - 2016-05-30 10:10 -0500
  Re: Software for MISC M17 Cecil Bayona <cbayona@cbayona.com> - 2016-05-30 17:07 -0500
    Re: Software for MISC M17 Cecil Bayona <cbayona@cbayona.com> - 2016-06-07 13:07 -0500
  Re: Software for MISC M17 hughaguilar96@gmail.com - 2016-05-30 18:10 -0700
    Re: Software for MISC M17 hughaguilar96@gmail.com - 2016-05-30 20:24 -0700
    Re: Software for MISC M17 Cecil Bayona <cbayona@cbayona.com> - 2016-05-31 00:13 -0500
      Re: Software for MISC M17 Mat <dambere@web.de> - 2016-06-07 02:24 -0700
        Re: Software for MISC M17 Cecil Bayona <cbayona@cbayona.com> - 2016-06-07 11:24 -0500
          Re: Software for MISC M17 jim.brakefield@ieee.org - 2016-06-07 11:13 -0700
          Re: Software for MISC M17 rickman <gnuarm@gmail.com> - 2016-06-07 19:15 -0400
            Re: Software for MISC M17 Cecil Bayona <cbayona@cbayona.com> - 2016-06-07 19:08 -0500
    Re: Software for MISC M17 Cecil Bayona <cbayona@cbayona.com> - 2016-06-06 12:49 -0500
      Re: Software for MISC M17 Jan Coombs <jenfhaomndgfwutc@murmic.plus.com> - 2016-06-07 11:00 +0100
        Re: Software for MISC M17 Cecil Bayona <cbayona@cbayona.com> - 2016-06-07 10:58 -0500
          Re: Software for MISC M17 Jan Coombs <jenfhaomndgfwutc@murmic.plus.com> - 2016-06-11 22:45 +0100
            Re: Software for MISC M17 Cecil Bayona <cbayona@cbayona.com> - 2016-06-11 17:29 -0500
              Re: Software for MISC M17 Jan Coombs <jenfhaomndgfwutc@murmic.plus.com> - 2016-06-12 13:07 +0100
  Re: Software for MISC M17 Jan Coombs <jenfhaomndgfwutc@murmic.plus.com> - 2016-06-07 10:35 +0100
    Re: Software for MISC M17 Cecil Bayona <cbayona@cbayona.com> - 2016-06-07 11:12 -0500
    Re: Software for MISC M17 Cecil Bayona <cbayona@cbayona.com> - 2016-06-08 15:43 -0500
      Re: Software for MISC M17 Lars Brinkhoff <lars.spam@nocrew.org> - 2016-06-09 09:32 +0200
        Re: Software for MISC M17 Cecil Bayona <cbayona@cbayona.com> - 2016-06-09 10:03 -0500

csiph-web