Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

tb/asmicon/bankmachine: test buffer and NACK

  • Loading branch information...
commit b1e5b9ef36634fdfb01f5a8ccfe2203ebb45e6cd 1 parent c129c98
Sébastien Bourdeauducq authored March 31, 2012

Showing 1 changed file with 13 additions and 4 deletions. Show diff stats Hide diff stats

  1. 17  tb/asmicon/selector.py
17  tb/asmicon/selector.py
... ...
@@ -1,3 +1,5 @@
  1
+from random import Random
  2
+
1 3
 from migen.fhdl.structure import *
2 4
 from migen.bus.asmibus import *
3 5
 from migen.sim.generic import Simulator, TopLevel
@@ -24,18 +26,25 @@ def my_generator(dt, offset):
24 26
 class Selector:
25 27
 	def __init__(self, slicer, bankn, slots):
26 28
 		self.selector = _Selector(slicer, bankn, slots)
  29
+		self.buf = _Buffer(self.selector)
27 30
 		self.queue = []
  31
+		self.prng = Random(876)
28 32
 	
29 33
 	def do_simulation(self, s):
30  
-		if s.rd(self.selector.stb):
31  
-			tag = s.rd(self.selector.tag)
  34
+		if self.prng.randrange(0, 5):
  35
+			s.wr(self.buf.ack, 1)
  36
+		else:
  37
+			s.wr(self.buf.ack, 0)
  38
+		if s.rd(self.buf.stb) and s.rd(self.buf.ack):
  39
+			tag = s.rd(self.buf.tag)
32 40
 			self.queue.append(tag)
33 41
 			print("==> SELECTED: " + str(tag))
34 42
 		print("")
35 43
 	
36 44
 	def get_fragment(self):
37  
-		comb = [self.selector.ack.eq(1)]
38  
-		return self.selector.get_fragment() + Fragment(comb, sim=[self.do_simulation])
  45
+		return self.selector.get_fragment() + \
  46
+			self.buf.get_fragment() + \
  47
+			Fragment(sim=[self.do_simulation])
39 48
 
40 49
 class Completer:
41 50
 	def __init__(self, hub, queue):

0 notes on commit b1e5b9e

Please sign in to comment.
Something went wrong with that request. Please try again.