mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 03:32:29 +00:00 
			
		
		
		
	Merge pull request #3924 from andyfox-rushc/master
multpass -- create Booth Encoded multipliers for
This commit is contained in:
		
						commit
						54be4aca90
					
				
					 5 changed files with 1561 additions and 36 deletions
				
			
		|  | @ -4,6 +4,7 @@ OBJS += passes/techmap/techmap.o | |||
| OBJS += passes/techmap/simplemap.o | ||||
| OBJS += passes/techmap/dfflibmap.o | ||||
| OBJS += passes/techmap/maccmap.o | ||||
| OBJS += passes/techmap/booth.o | ||||
| OBJS += passes/techmap/libparse.o | ||||
| 
 | ||||
| ifeq ($(ENABLE_ABC),1) | ||||
|  |  | |||
							
								
								
									
										1524
									
								
								passes/techmap/booth.cc
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1524
									
								
								passes/techmap/booth.cc
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -17,17 +17,16 @@ | |||
|  * | ||||
|  */ | ||||
| 
 | ||||
| #include "kernel/register.h" | ||||
| #include "kernel/celltypes.h" | ||||
| #include "kernel/rtlil.h" | ||||
| #include "kernel/log.h" | ||||
| #include "kernel/register.h" | ||||
| #include "kernel/rtlil.h" | ||||
| 
 | ||||
| USING_YOSYS_NAMESPACE | ||||
| PRIVATE_NAMESPACE_BEGIN | ||||
| 
 | ||||
| struct SynthPass : public ScriptPass | ||||
| { | ||||
| 	SynthPass() : ScriptPass("synth", "generic synthesis script") { } | ||||
| struct SynthPass : public ScriptPass { | ||||
| 	SynthPass() : ScriptPass("synth", "generic synthesis script") {} | ||||
| 
 | ||||
| 	void help() override | ||||
| 	{ | ||||
|  | @ -60,6 +59,9 @@ struct SynthPass : public ScriptPass | |||
| 		log("    -noabc\n"); | ||||
| 		log("        do not run abc (as if yosys was compiled without ABC support)\n"); | ||||
| 		log("\n"); | ||||
| 		log("    -booth\n"); | ||||
| 		log("        run the booth pass to convert $mul to Booth encoded multipliers"); | ||||
| 		log("\n"); | ||||
| 		log("    -noalumacc\n"); | ||||
| 		log("        do not run 'alumacc' pass. i.e. keep arithmetic operators in\n"); | ||||
| 		log("        their direct form ($add, $sub, etc.).\n"); | ||||
|  | @ -93,7 +95,8 @@ struct SynthPass : public ScriptPass | |||
| 	} | ||||
| 
 | ||||
| 	string top_module, fsm_opts, memory_opts, abc; | ||||
| 	bool autotop, flatten, noalumacc, nofsm, noabc, noshare, flowmap; | ||||
| 	bool autotop, flatten, noalumacc, nofsm, noabc, noshare, flowmap, booth; | ||||
| 
 | ||||
| 	int lut; | ||||
| 
 | ||||
| 	void clear_flags() override | ||||
|  | @ -110,6 +113,7 @@ struct SynthPass : public ScriptPass | |||
| 		noabc = false; | ||||
| 		noshare = false; | ||||
| 		flowmap = false; | ||||
| 		booth = false; | ||||
| 		abc = "abc"; | ||||
| 	} | ||||
| 
 | ||||
|  | @ -119,24 +123,23 @@ struct SynthPass : public ScriptPass | |||
| 		clear_flags(); | ||||
| 
 | ||||
| 		size_t argidx; | ||||
| 		for (argidx = 1; argidx < args.size(); argidx++) | ||||
| 		{ | ||||
| 			if (args[argidx] == "-top" && argidx+1 < args.size()) { | ||||
| 		for (argidx = 1; argidx < args.size(); argidx++) { | ||||
| 			if (args[argidx] == "-top" && argidx + 1 < args.size()) { | ||||
| 				top_module = args[++argidx]; | ||||
| 				continue; | ||||
| 			} | ||||
| 			if (args[argidx] == "-encfile" && argidx+1 < args.size()) { | ||||
| 			if (args[argidx] == "-encfile" && argidx + 1 < args.size()) { | ||||
| 				fsm_opts = " -encfile " + args[++argidx]; | ||||
| 				continue; | ||||
| 			} | ||||
| 			if (args[argidx] == "-run" && argidx+1 < args.size()) { | ||||
| 				size_t pos = args[argidx+1].find(':'); | ||||
| 			if (args[argidx] == "-run" && argidx + 1 < args.size()) { | ||||
| 				size_t pos = args[argidx + 1].find(':'); | ||||
| 				if (pos == std::string::npos) { | ||||
| 					run_from = args[++argidx]; | ||||
| 					run_to = args[argidx]; | ||||
| 				} else { | ||||
| 					run_from = args[++argidx].substr(0, pos); | ||||
| 					run_to = args[argidx].substr(pos+1); | ||||
| 					run_to = args[argidx].substr(pos + 1); | ||||
| 				} | ||||
| 				continue; | ||||
| 			} | ||||
|  | @ -164,6 +167,11 @@ struct SynthPass : public ScriptPass | |||
| 				noalumacc = true; | ||||
| 				continue; | ||||
| 			} | ||||
| 			if (args[argidx] == "-booth") { | ||||
| 				booth = true; | ||||
| 				continue; | ||||
| 			} | ||||
| 
 | ||||
| 			if (args[argidx] == "-nordff") { | ||||
| 				memory_opts += " -nordff"; | ||||
| 				continue; | ||||
|  | @ -206,8 +214,7 @@ struct SynthPass : public ScriptPass | |||
| 
 | ||||
| 	void script() override | ||||
| 	{ | ||||
| 		if (check_label("begin")) | ||||
| 		{ | ||||
| 		if (check_label("begin")) { | ||||
| 			if (help_mode) { | ||||
| 				run("hierarchy -check [-top <top> | -auto-top]"); | ||||
| 			} else { | ||||
|  | @ -221,8 +228,7 @@ struct SynthPass : public ScriptPass | |||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		if (check_label("coarse")) | ||||
| 		{ | ||||
| 		if (check_label("coarse")) { | ||||
| 			run("proc"); | ||||
| 			if (help_mode || flatten) | ||||
| 				run("flatten", "  (if -flatten)"); | ||||
|  | @ -240,6 +246,8 @@ struct SynthPass : public ScriptPass | |||
| 				run("techmap -map +/cmp2lut.v -map +/cmp2lcu.v", " (if -lut)"); | ||||
| 			else if (lut) | ||||
| 				run(stringf("techmap -map +/cmp2lut.v -map +/cmp2lcu.v -D LUT_WIDTH=%d", lut)); | ||||
| 			if (booth) | ||||
| 				run("booth"); | ||||
| 			if (!noalumacc) | ||||
| 				run("alumacc", "  (unless -noalumacc)"); | ||||
| 			if (!noshare) | ||||
|  | @ -249,50 +257,40 @@ struct SynthPass : public ScriptPass | |||
| 			run("opt_clean"); | ||||
| 		} | ||||
| 
 | ||||
| 		if (check_label("fine")) | ||||
| 		{ | ||||
| 		if (check_label("fine")) { | ||||
| 			run("opt -fast -full"); | ||||
| 			run("memory_map"); | ||||
| 			run("opt -full"); | ||||
| 			run("techmap"); | ||||
| 			if (help_mode) | ||||
| 			{ | ||||
| 			if (help_mode) { | ||||
| 				run("techmap -map +/gate2lut.v", "(if -noabc and -lut)"); | ||||
| 				run("clean; opt_lut", "           (if -noabc and -lut)"); | ||||
| 				run("flowmap -maxlut K", "        (if -flowmap and -lut)"); | ||||
| 			} | ||||
| 			else if (noabc && lut) | ||||
| 			{ | ||||
| 			} else if (noabc && lut) { | ||||
| 				run(stringf("techmap -map +/gate2lut.v -D LUT_WIDTH=%d", lut)); | ||||
| 				run("clean; opt_lut"); | ||||
| 			} | ||||
| 			else if (flowmap) | ||||
| 			{ | ||||
| 			} else if (flowmap) { | ||||
| 				run(stringf("flowmap -maxlut %d", lut)); | ||||
| 			} | ||||
| 			run("opt -fast"); | ||||
| 
 | ||||
| 			if (!noabc && !flowmap) { | ||||
| 		#ifdef YOSYS_ENABLE_ABC | ||||
| 				if (help_mode) | ||||
| 				{ | ||||
| #ifdef YOSYS_ENABLE_ABC | ||||
| 				if (help_mode) { | ||||
| 					run(abc + " -fast", "       (unless -noabc, unless -lut)"); | ||||
| 					run(abc + " -fast -lut k", "(unless -noabc, if -lut)"); | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 				} else { | ||||
| 					if (lut) | ||||
| 						run(stringf("%s -fast -lut %d", abc.c_str(), lut)); | ||||
| 					else | ||||
| 						run(abc + " -fast"); | ||||
| 				} | ||||
| 				run("opt -fast", "       (unless -noabc)"); | ||||
| 		#endif | ||||
| #endif | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		if (check_label("check")) | ||||
| 		{ | ||||
| 		if (check_label("check")) { | ||||
| 			run("hierarchy -check"); | ||||
| 			run("stat"); | ||||
| 			run("check"); | ||||
|  |  | |||
							
								
								
									
										1
									
								
								tests/techmap/booth.ys
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								tests/techmap/booth.ys
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | |||
| test_cell -s 1694091355 -n 1000 -script booth_map_script.ys_ $mul | ||||
							
								
								
									
										1
									
								
								tests/techmap/booth_map_script.ys_
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								tests/techmap/booth_map_script.ys_
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | |||
| booth | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue